package com.four.peoplemanage.gopolice.controller;

import com.four.peoplemanage.common.bean.ResponseData;
import com.four.peoplemanage.common.controller.BaseController;
import com.four.peoplemanage.gopolice.entity.Gopolice;
import com.four.peoplemanage.gopolice.service.GopoliceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/gopolice")
public class GopoliceController extends BaseController {
    @Autowired
    GopoliceService gopoliceService;

    //申请出警
    @PostMapping("/insert")
    public ResponseData<Boolean> insertGopolice(Gopolice gopolice){
        return returnBoolean(gopoliceService.insert(gopolice));
    }

    //分页
    @GetMapping("/getAll")
    public ResponseData<Object>  getAll(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "applicants",required = false) String applicants,
            @RequestParam(value = "department",required = false) String department,
            @RequestParam(value = "status",required = false) String status


    ){
        return returnObject(gopoliceService.getPageGopolice(pageNum, pageSize, applicants, department,status));
    }
    //分页
    @GetMapping("/getone")
    public ResponseData<Object>  getOne(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "applicants",required = false) String applicants,
            @RequestParam(value = "department",required = false) String department,
            @RequestParam(value = "status",required = false) String status,
            @RequestParam(value = "information_id",required = false) int information_id


    ){
        return returnObject(gopoliceService.getOneGopolice(pageNum, pageSize, applicants, department,information_id,status));
    }

    //更新状态可撤销
    @PutMapping("/updateS")
    public  ResponseData<Boolean> updateS(@RequestBody Gopolice gopolice){
        return returnBoolean(gopoliceService.updateStatus(gopolice));
    }
    //通过
    @PutMapping("/receive")
    public  ResponseData<Boolean> receive(@RequestBody Gopolice gopolice){
        return returnBoolean(gopoliceService.updateSuccess(gopolice));
    }
    //驳回
    @PutMapping("/reject")
    public  ResponseData<Boolean> reject(@RequestBody Gopolice gopolice){
        return returnBoolean(gopoliceService.updateFail(gopolice));
    }

    //编辑
    @PutMapping("/update")
    public ResponseData<Boolean> update(@RequestBody Gopolice gopolice){
        return returnBoolean(gopoliceService.updateGopolice(gopolice));
    }

}
